package cn.jimmie.lib.qlog.support;

import android.text.TextUtils;

import java.util.Locale;

/**
 * Func :
 *
 * <p> Create Time:  2019-07-22 16:56 </p>
 * <p> @author Jimmie.Qian  </p>
 */
public class AlString {
    public static final String NULL = "";

    public static String nonNull(String source) {
        if (TextUtils.isEmpty(source)) return NULL;
        return source;
    }

    public static boolean empty(String str) {
        return null == str || str.isEmpty();
    }

    public static String format(String source, Object... args) {
        try {
            return String.format(Locale.CHINA, source, args);
        } catch (Exception e) {
            return NULL;
        }
    }

    public static boolean notEmpty(String str) {
        return !empty(str);
    }

    public static String trim(String str) {
        if (str == null) return NULL;
        return str.trim();
    }
}
